//
// Decompiled by Jadx - 854ms
//
package fn;

import a.g;
import a.i;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.os.Message;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import fi.a;
import fm.c;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import me.plusne.GreenDao.dao.ConfigDao;
import me.plusne.NativeTools;
import me.plusne.common.Json.JsonHookStatic;
import me.plusne.common.Json.Login.JsonHookDataDecrypt;

@SuppressLint({"StaticFieldLeak"})
public class y extends j {
    public static int bw;
    public static int bx;
    public static final JsonHookStatic by = new JsonHookStatic();
    public static ClassLoader bz;
    public static final HashMap<String, String> ca;

    static {
        HashMap<String, String> hashMap = new HashMap<>();
        ca = hashMap;
        hashMap.put("com.tencent.mm", "WX");
        hashMap.put("com.ss.android.ugc.aweme", "DY");
        hashMap.put("com.ss.android.ugc.aweme.lite", "DYJS");
        hashMap.put("cn.soulapp.android", "SOUL");
        hashMap.put("com.dragon.read", "FQ");
        hashMap.put("com.xs.fm", "FQCT");
        hashMap.put("com.kmxs.reader", "QM");
        hashMap.put("com.kuaishou.nebula", "KSJS");
        hashMap.put("com.smile.gifmaker", "KS");
        hashMap.put("com.xingin.xhs", "XHS");
        hashMap.put("cn.xiaochuankeji.tieba", "ZY");
        hashMap.put("com.ss.android.article.video", "XG");
        hashMap.put("cn.xiaochuankeji.zuiyouLite", "PPGX");
        hashMap.put("com.sup.android.superb", "PPX");
        hashMap.put("com.immomo.momo", "MOMO");
        hashMap.put("com.estrongs.android.pop", "ES");
        hashMap.put("com.baidu.tieba", "TB");
        hashMap.put("com.zhiliaoapp.musically", "TK");
        hashMap.put("com.tencent.mobileqq", "QQ");
        hashMap.put("com.tmri.app.main", "JG");
        hashMap.put("com.soul.android.international", "SC");
    }

    public static double cb(String str) {
        JsonHookStatic jsonHookStatic = by;
        double d = 0.0d;
        if (jsonHookStatic.isExpire() || jsonHookStatic.getHookData() == null || !j.bg()) {
            return 0.0d;
        }
        String trim = str.trim();
        Object obj = jsonHookStatic.getSetList().get(trim);
        try {
            if (obj != null) {
                return Double.parseDouble(String.valueOf(obj));
            }
            if (jsonHookStatic.getDb() == null) {
                return 0.0d;
            }
            ConfigDao configDao = jsonHookStatic.getDb().q;
            configDao.getClass();
            g gVar = new g(configDao);
            gVar.l(ConfigDao.Properties.Key.f(trim), new i[0]);
            gVar.i(1);
            c cVar = (c) gVar.k();
            if (cVar != null) {
                d = Double.parseDouble(cVar.c);
            }
            jsonHookStatic.getSetList().put(trim, Double.valueOf(d));
            return d;
        } catch (NumberFormatException e) {
            e.printStackTrace();
            return 0.0d;
        }
    }

    public static float cc(float f) {
        JsonHookStatic jsonHookStatic = by;
        if (jsonHookStatic.isExpire() || jsonHookStatic.getHookData() == null || !j.bg()) {
            return 0.0f;
        }
        Object obj = jsonHookStatic.getSetList().get("KeepSpeedNum");
        try {
            if (obj != null) {
                return Float.parseFloat(String.valueOf(obj));
            }
            if (jsonHookStatic.getDb() != null) {
                ConfigDao configDao = jsonHookStatic.getDb().q;
                configDao.getClass();
                g gVar = new g(configDao);
                gVar.l(ConfigDao.Properties.Key.f("KeepSpeedNum"), new i[0]);
                gVar.i(1);
                c cVar = (c) gVar.k();
                if (cVar != null) {
                    f = Float.parseFloat(cVar.c);
                }
                jsonHookStatic.getSetList().put("KeepSpeedNum", Float.valueOf(f));
                return f;
            }
            return f;
        } catch (NumberFormatException e) {
            e.printStackTrace();
            return f;
        }
    }

    public static int cd(int i, String str) {
        JsonHookStatic jsonHookStatic = by;
        if (jsonHookStatic.isExpire() || jsonHookStatic.getHookData() == null || !j.bg()) {
            return 0;
        }
        return b.f(i, str.trim());
    }

    public static long ce(long j, String str) {
        JsonHookStatic jsonHookStatic = by;
        if (jsonHookStatic.isExpire() || jsonHookStatic.getHookData() == null || !j.bg()) {
            return 0L;
        }
        String trim = str.trim();
        Object obj = jsonHookStatic.getSetList().get(trim);
        if (obj != null) {
            if (obj instanceof String) {
                return Long.parseLong((String) obj);
            }
            return ((Long) obj).longValue();
        }
        if (jsonHookStatic.getDb() != null) {
            ConfigDao configDao = jsonHookStatic.getDb().q;
            configDao.getClass();
            g gVar = new g(configDao);
            gVar.l(ConfigDao.Properties.Key.f(trim), new i[0]);
            gVar.i(1);
            c cVar = (c) gVar.k();
            if (cVar != null) {
                j = Long.parseLong(cVar.c);
            }
            jsonHookStatic.getSetList().put(trim, Long.valueOf(j));
            return j;
        }
        return j;
    }

    public static String cf(String str, String str2) {
        JsonHookStatic jsonHookStatic = by;
        if (jsonHookStatic.isExpire() || jsonHookStatic.getHookData() == null || !j.bg()) {
            return null;
        }
        return b.g(str.trim(), str2.trim());
    }

    public static List<a> cg(String str) {
        String g = b.g(str.trim(), "");
        if (g != null) {
            try {
                return (List) new Gson().fromJson(g, new a().getType());
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
        return null;
    }

    public static boolean ch(String str, boolean z) {
        JsonHookStatic jsonHookStatic = by;
        if (jsonHookStatic.isExpire() || jsonHookStatic.getHookData() == null || !j.bg()) {
            return false;
        }
        return b.h(str.trim(), z);
    }

    public static int ci() {
        int i = bw;
        JsonHookStatic jsonHookStatic = by;
        if (i == 0 || bx == 0) {
            DisplayMetrics displayMetrics = new DisplayMetrics();
            jsonHookStatic.getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
            bw = displayMetrics.heightPixels / 3;
            bx = displayMetrics.widthPixels / 3;
        }
        if (jsonHookStatic.getDouble_X() <= bx && jsonHookStatic.getDouble_Y() <= bw) {
            return 1;
        }
        if (jsonHookStatic.getDouble_X() > bx && jsonHookStatic.getDouble_X() <= bx * 2 && jsonHookStatic.getDouble_Y() <= bw) {
            return 2;
        }
        if (jsonHookStatic.getDouble_X() > bx * 2 && jsonHookStatic.getDouble_X() <= bx * 3 && jsonHookStatic.getDouble_Y() <= bw) {
            return 3;
        }
        if (jsonHookStatic.getDouble_X() <= bx && jsonHookStatic.getDouble_Y() <= bw * 2) {
            return 4;
        }
        if (jsonHookStatic.getDouble_X() > bx && jsonHookStatic.getDouble_X() <= bx * 2 && jsonHookStatic.getDouble_Y() <= bw * 2 && jsonHookStatic.getDouble_Y() > bw) {
            return 5;
        }
        if (jsonHookStatic.getDouble_X() > bx * 2 && jsonHookStatic.getDouble_X() <= bx * 3 && jsonHookStatic.getDouble_Y() <= bw * 2 && jsonHookStatic.getDouble_Y() > bw) {
            return 6;
        }
        if (jsonHookStatic.getDouble_X() <= bx && jsonHookStatic.getDouble_Y() <= bw * 3 && jsonHookStatic.getDouble_Y() > bw * 2) {
            return 7;
        }
        if (jsonHookStatic.getDouble_X() <= bx || jsonHookStatic.getDouble_X() > bx * 2 || jsonHookStatic.getDouble_Y() > bw * 3 || jsonHookStatic.getDouble_Y() <= bw * 2) {
            return (jsonHookStatic.getDouble_X() <= ((float) (bx * 2)) || jsonHookStatic.getDouble_X() > ((float) (bx * 3)) || jsonHookStatic.getDouble_Y() > ((float) (bw * 3)) || jsonHookStatic.getDouble_Y() <= ((float) (bw * 2))) ? 0 : 9;
        }
        return 8;
    }

    public static String cj(String str) {
        return ck(str, "");
    }

    public static String ck(String str, String str2) {
        String l;
        JsonHookStatic jsonHookStatic = by;
        if (jsonHookStatic != null && !jsonHookStatic.isExpire() && str != null) {
            String trim = str.trim();
            if (jsonHookStatic.getHookData() == null) {
                return str2.trim();
            }
            for (JsonHookDataDecrypt jsonHookDataDecrypt : jsonHookStatic.getHookData()) {
                if (jsonHookDataDecrypt.getKey().equals(trim)) {
                    if (jsonHookDataDecrypt.isInit()) {
                        l = jsonHookDataDecrypt.getValue();
                    } else {
                        if (jsonHookDataDecrypt.getValue() == null) {
                            jsonHookDataDecrypt.setValue("");
                        }
                        l = NativeTools.l(jsonHookDataDecrypt.getValue(), String.valueOf(jsonHookStatic.getTimeDecrypt()), jsonHookStatic.getUserInfo().getUser().toLowerCase());
                        jsonHookDataDecrypt.setInit(true);
                        jsonHookDataDecrypt.setValue(l);
                    }
                    return TextUtils.isEmpty(l) ? TextUtils.isEmpty(str2) ? "" : str2.trim() : l.trim();
                }
            }
            return str2.trim();
        }
        return str2.trim();
    }

    public static boolean cl(String str, List list) {
        if (!TextUtils.isEmpty(str) && list != null && !list.isEmpty()) {
            Iterator it = list.iterator();
            while (it.hasNext()) {
                if (str.trim().contains(((a) it.next()).getKey().trim())) {
                    return true;
                }
            }
        }
        return false;
    }

    public static void cm(Serializable serializable) {
        Message message = new Message();
        Bundle bundle = new Bundle();
        bundle.putSerializable("key", serializable);
        message.setData(bundle);
        JsonHookStatic jsonHookStatic = by;
        if (jsonHookStatic.getHandler() != null) {
            jsonHookStatic.getHandler().sendMessage(message);
        }
    }

    public static String cn(Class cls, String str, boolean z) {
        for (Field field : cls.getDeclaredFields()) {
            String name = field.getType().getName();
            String trim = str.trim();
            if (z) {
                if (name.startsWith(trim)) {
                    return field.getName();
                }
            } else if (name.equals(trim)) {
                return field.getName();
            }
        }
        j.bi(new Object[]{cls, "自适配失败Field"});
        return null;
    }

    public static void co(Object obj, String str) {
        if (str != null) {
            str = str.trim();
        }
        b.l(obj, str);
    }
}
